<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>



		<style>
			* {
				margin: 0;
				padding: 0;
				box-sizing: border-box;
				font-size: 15px;
				font-weight: 500;
				font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
			}

			body {
				width: 100%;
			}

			.box-1 {
				width: 100%;

				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
			}

			button {
				padding: 10px 30px;
				box-sizing: border-box;
				margin-top: 10px;
			}

			input {
				width: 140px;
				height: 40px;
			}

			.box-2 {
				width: 100%;
				margin-top: 10px;

			}

			.items {
				width: 33%;
				display: inline-block;
				text-align: center;
				font-size: 12px;
				margin-top: 10px;
			}
		</style>
	</head>

	<body>
		<div class="box" id="app">
			<div class="box-1">
				<input id="searchTxt" type="number">
				<button id="btns" onclick="myBtn()" type="button">发送验证码</button>
			</div>
			<div class="box-1">
				<button id="btn2" onclick="myBtn2()" type="button">开始注册</button>
			</div>


			<div class="box-2" id="box2">
			</div>
		</div>
		<script src="https://cdn.suoluomei.com/common/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript">
			var urls = 'https://apptest.wjcqedu.com/login/code'
			var urls2 = 'https://apptest.wjcqedu.com/login/register'

			function myBtn2() {
				var values = document.getElementById("searchTxt").value;
				for (var i = 0; i < values; i++) {
					var mobile = getMoble();

					resMobile(mobile)
				}


			}

			function resMobile(mobile) {
				const self = this;
				$.ajax({
					type: "POST",
					url: self.urls2,
					headers: {
					},
					data: {
						mobile: mobile,
						password: 'a123456',
						code: 666666,
						role_id: 1,
						province_id: 0,
						city_id: 0,
						area_id: 0,
						region: '东湖区',
						address: '人民公园',
						lng_lat: '115.91,28.68'
					},
					success: function(res) {
						if (res.code == 1) {}
					},
					error: function(err) {
						alert(err)
					}
				});

			}


			function myBtn() {
				send();
			}

			function send() {
				var values = document.getElementById("searchTxt").value;

				for (var i = 0; i < values; i++) {
					var mobile = getMoble();
					var ulll = document.getElementById("box2");
					var divv = document.createElement("div");
					divv.innerHTML = '<div class="items">' + i + '、' + mobile + '</div>';
					ulll.appendChild(divv);




					sendMobile(mobile)
				}
			}

			function sendMobile(mobile) {
				const self = this;
				$.ajax({
					type: "POST",
					url: self.urls,
					headers: {

					},
					data: {
						mobile: mobile,
						type: 1
					},
					success: function(res) {
						if (res.code == 1) {} else {
							alert(res.data.msg)
						}
					},
					error: function(err) {
						alert(err)
					}
				});

			}

			function getMoble() {

				var prefixArray = new Array('130', '131', '132', '133', '135', '137', '138', '170', '187',
					'189');

				var i = parseInt(10 * Math.random());

				var prefix = prefixArray[i];

				for (var j = 0; j < 8; j++) {
					prefix = prefix + Math.floor(Math.random() * 10);
				}

				return prefix;
			}
		</script>
	</body>

</html>